package com.day01;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

//写一个自己的迭代器，从mysql数据库中读取数据，封装底层的逻辑
//一次返回一行数据，并且封装成对象返回
public class Test {
    public static void main(String[] args) throws Exception {
/*

        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }


        HashSet<Integer> set = new HashSet<>();
        set.add(1);
        set.add(2);
        set.add(3);
        set.add(4);

        Iterator<Integer> iterator1 = set.iterator();
        while (iterator1.hasNext()){
            System.out.println(iterator1.next());
        }
*/

       /* MyIterator myIterator = new MyIterator();
        while (myIterator.hasNext()){
            Hero next = myIterator.next();
            System.out.println(next);
        }*/


        MysqlIterator mysqlIterator = new MysqlIterator();
        while (mysqlIterator.hasNext()){
            System.out.println(mysqlIterator.next());
        }

    }
}
